package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Author：毕龙
 * Date: 2023/7/27 17:34
 */
@WebServlet("/sess")
public class ServletSession1 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取session
        HttpSession session = request.getSession();
        //设置session失效时间
        session.setMaxInactiveInterval(10);

        String id = session.getId();
        System.out.println("seesionid:"+id);

        session.setAttribute("name","张和青");
        session.setAttribute("list","张和青wujiayutoaling");


    }
}
